SHELL=bash

include config.mk

CLEAN_OBJS=*.o
REALCLEAN_OBJS=

HADOOP_LIB_PATH=$(HADOOP_PATH)/lib

EXTDIR=../ext
EXT=

V8LIBPATH=$(EXTDIR)/v8/libv8.a
V8INCLUDEPATH=$(EXTDIR)/v8/include

CFLAGS=\
  -m32 \
  -pedantic \
  -Wall \
  -g 

CCFLAGS=\
  -m32 \
  -pedantic \
  -Wall \
  -g  \
  -I$(V8INCLUDEPATH) \
  -I$(HADOOP_PATH)/include \
  -lpthread

LDFLAGS= -L$(HADOOP_LIB_PATH) 

LIBTOOL = $(EXTDIR)/libcurl/libtool
CURLLIBDIR = $(EXTDIR)/libcurl/lib
CURLH=$(EXTDIR)/libcurl/include
LINK=$(LIBTOOL) --tag=CC --mode=link g++ $(CFLAGS) $(LDFLAGS) -o $@

hadoop_ld=\
  $(HADOOP_LIB_PATH)/libhadooppipes.a \
  $(HADOOP_LIB_PATH)/libhadooputils.a \
  $(LIBHDFS_LIBS) \
  $(V8LIBPATH) \
  $(CURLLIBDIR)/libcurl.la \

hadoop_libs=\
  -I$(LIBHDFS) \
  -I$(JNI_MD_H) \
  -I$(JNI_H) \
  -I$(CURLH) \
  -I$(V8INCLUDEPATH)


CLEAN_OBJ=

all: test



test_container.o: test_container.cc  
	g++ -c -o $@ $< $(CCFLAGS) $(hadoop_libs) -I$(EXTDIR)/googletest/include
CLEAN_OBJ+=test_container.o

test_container: test_container.o ../jsmr.o $(EXTDIR)/urlparser/urlparser.o $(EXTDIR)/v8/libv8.a $(EXTDIR)/googletest/lib/libgtest.la
	$(LINK)  test_container.o $(hadoop_libs) $(hadoop_ld) ../jsmr.o \
    $(EXTDIR)/urlparser/urlparser.o $(EXTDIR)/googletest/lib/libgtest.la; 
CLEAN_OBJ+=test_container
CLEAN_OBJ+=.libs/test_container



test: test_container
	@export LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):../lib; \
	export CLASSPATH=$$CLASSPATH:$(CLASSPATH); \
	./test_container	
CLEAN_OBJ+=test_container

clean:
	rm -f $(CLEAN_OBJ) ; \
	rm -rf .libs
